class HttpException extends Error {
  constructor(msg = '服务器异常', errorCode = 10000, code = 400) {
    super()
    this.msg = msg
    this.errorCode = errorCode
  }
}

class Success extends HttpException {
  constructor(data, msg = '成功', errorCode) {
    super()
    this.msg = msg
    this.data = data || null
    this.errorCode = errorCode || 0
  }
}

class ParameterException extends HttpException {
  constructor(msg, errorCode) {
    super()
    this.msg = msg || '参数错误'
    this.errorCode = errorCode || 10
  }
}

class NotFound extends HttpException{
  constructor(msg, errorCode) {
      super()
      this.msg = msg || '资源未找到'
      this.errorCode = errorCode || 20
  }
}

class Forbbiden extends HttpException{
  constructor(msg, errorCode) {
      super()
      this.msg = msg || '禁止访问'
      this.errorCode = errorCode || 30
  }
}

class notRestiger extends HttpException{
  constructor(msg, errorCode) {
      super()
      this.msg = msg || '用户已被注册'
      this.errorCode = errorCode || 1000
  }
}

class AuthFailed extends HttpException{
  constructor(msg, errorCode) {
      super()
      this.msg = msg || '登录账号或密码错误'
      this.errorCode = errorCode || 1001
  }
}

class CreateAuthFailed extends HttpException{
  constructor(msg, errorCode) {
      super()
      this.msg = msg || '创建账号失败'
      this.errorCode = errorCode || 1002
  }
}

class fileUploadError extends HttpException{
  constructor(msg, errorCode) {
      super()
      this.msg = msg || '不支持文件类型上传'
      this.errorCode = errorCode || 1004
  }
}

module.exports = {
  HttpException,
  ParameterException,
  Success,
  NotFound,
  Forbbiden,
  notRestiger,
  AuthFailed,
  CreateAuthFailed,
  BlogAddFailed,
  fileUploadError
}